<?php defined('_JEXEC') or die('Restricted access'); 

JHTML::_('behavior.tooltip');
JHTML::_('behavior.mootools');

$document=JFactory::getDocument();
$document->addStyleSheet('components/com_yos_news_crawler/assets/css/job_edit.css');
$document->addScript('components/com_yos_news_crawler/assets/js/job.js');
$document->addScript('http://www.google.com/jsapi');
$document->addScriptDeclaration($this->script);
jimport('joomla.html.pane');
$tab_active=JRequest::getVar('tab_active',0);
$pane =& JPane::getInstance('tabs',array('startOffset'=>$tab_active)); 

$job=$this->job;
?>
<script>
window.addEvent('load', function() {
	var c_from = $('t_from').getChildren('option');	
	for (i = 0 ; i< c_from.length; i++) {		
		if (c_from[i].getProperty('value') == '<?php echo $job->t_from; ?>'){
			c_from[i].setProperty('selected','true');
			i= c_from.length;
		}
	}
	
	var c_to = $('t_to').getChildren('option');
	for (i =0 ; i< c_to.length; i++) {
		if (c_to[i].getProperty('value')== '<?php echo $job->t_to; ?>'){
			c_to[i].setProperty('selected','true');
			i= c_to.length;
		}
	}
	
});

</script>
<div class="edit_job">
	<form action="index.php?option=com_yos_news_crawler" method="post" name="adminForm">
		<?php
		echo $pane->startPane( 'pane' );
		// PANEL 1
		/*BEGIN STEP 1*/
		echo $pane->startPanel( JText::_('Get content'), 'getcontent' );		
			?>		
				<div class="left"><?php echo JText::_('title')?></div>
				<div class="right"><input name="title" type="text" value="<?php echo $job->title?>" /> </div>
				<div class="clr"></div>		
				<div class="left"><?php echo JText::_('Time update (Minute)')?></div>
				<div class="right"><input name="time_update" type="text" value="<?php echo $job->time_update?>" /> </div>
				<div class="clr"></div>				
				<div class="left"><?php echo JText::_('  Select CMS')?></div>
				<div class="right"><?php echo $this->lists['cms']; ?></div>
				<div class="clr"></div>
				<div class="left"><?php echo JText::_('Select Link')?></div>
				<div class="right"><?php echo $this->lists['links']; ?></div>
				<div class="clr"></div>
				<div class="left"><?php echo JText::_('Copyright by')?></div>
				<div class="right"><input type="text" name="according_to" value="<?php echo $job->according_to?>" /></div>
				<div class="clr"></div>			
				
				<div title="" class="left texarea"><?php echo JText::_('Keyword [word]').JText::_(':')?><em><?php echo JText::_('Use keyword to filter data receive'); ?></em> </div>
				<div class="right">
					<textarea name="keyword" rows="5" cols="70"><?php echo $job->keyword; ?></textarea>			
				</div>
				<div class="clr"></div>		
					
		</param>	
		
		
		
		
			<?php
		echo $pane->endPanel();
		/*END PANEL 1*/
		
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		/*BEGIN STEP 2*/
		// PANEL 2
		echo $pane->startPanel( JText::_('CMS Configurations'), 'cms_config' );
			?>
				<div id="job_config_cms"></div>
			<?php
		echo $pane->endPanel();
		/*END PANEL 2*/
		
	 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		// PANEL 3
		echo $pane->startPanel( JText::_('Images'), 'images' );	
		?>
			<div class="left"><span class="editlinktip hasTip" title="Get Images::Gets images from remote site then stores in CMS site"><?php echo JText::_('Get Images').JText::_(':')?></span></div>
			<div class="right">
				<input type="radio" <?php if($job->get_img==0) echo 'checked'; ?> name="get_img" value="0" /> <?php echo JText::_('No')?>
				<input type="radio" <?php if($job->get_img==1) echo 'checked'; ?> name="get_img" value="1" /><?php echo JText::_('Yes')?>
			</div>
			<div class="clr"></div>
			<div class="left"><?php echo JText::_('Resize Images').JText::_(':')?></div>
			<div class="right">
				<input type="radio" <?php if($job->resizeimage==0) echo 'checked'; ?> name="resizeimage" value="0" /> <?php echo JText::_('No')?>
				<input type="radio" <?php if($job->resizeimage==1) echo 'checked'; ?> name="resizeimage" value="1" /><?php echo JText::_('Yes')?>
			</div>
			<div class="clr"></div>
			<div class="left"><span class="editlinktip hasTip" title="Max width (pixel)::Maximum width (after resized)"><?php echo JText::_('Images max width').JText::_(':')?></div>			
			<div class="right">
				<input type="text" checked name="images_max_width" value="<?php echo $job->images_max_width; ?>" /> 			
			</div>
			<div class="clr"></div>		
			<div class="left"><span class="editlinktip hasTip" title="Max height (pixel)::Maximum height (after resized)"><?php echo JText::_('Images max height').JText::_(':')?></span></div>			
			<div class="right">
				<input type="text" checked name="images_max_height" value="<?php echo $job->images_max_height; ?>" /> 			
			</div>
			<div class="clr"></div>				
		<?php
		echo $pane->endPanel();
		/*END PANEL 3*/
		
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// PANEL 4
		echo $pane->startPanel( JText::_('Other Tools'), 'tools' );
		?>
				<div class="clr"></div>
				<div class="left">
					<?php echo JText::_('Translate').JText::_(':'); ?><br />				
				</div>
				<div class="right">
				<?php  //echo $job->t_from.$job->t_to; ?>
					<input type="checkbox" id="trans" <?php if($job->t_from and $job->t_to) echo 'checked'; ?> name="trans" />				
				</div>
				<div class="clr"></div>
				<div class="left">				
					<span class="editlinktip hasTip" title="<?php echo JText::_( 'Translate From' );?>::<?php echo JText::_('Choose a language that you want translate'); ?>">
						<strong>Translate From:</strong>
					</span>
				</div>
				<div class="right">
					<select name="t_from" id="t_from"></select>
				</div>
				<div class="clr"></div>		
				<div class="left">
					<span class="editlinktip hasTip" title="<?php echo JText::_( 'Translate To' );?>::<?php echo JText::_('Choose a language that you want save in your database'); ?>">
						<strong>Translate To:</strong>						
					</span>
				</div>
				<div class="right">					
					<select name="t_to" id="t_to"></select>
				</div>				
				<div class="clr"></div>
				<div class="left">
					<?php echo JText::_('Rewrite').JText::_(':'); ?><br />
					<em><?php echo JText::_('English Article Only!'); ?></em>
				</div>
				<div class="right">				
					<input type="radio" <?php if($job->rewrite==0) echo 'checked'; ?> name="rewrite" value="0" /> <?php echo JText::_('No')?>
					<input type="radio" <?php if($job->rewrite==1) echo 'checked'; ?> name="rewrite" value="1" /><?php echo JText::_('Yes')?>
				</div>
				<div class="clr"></div>
		<?php
		echo $pane->endPanel();
		
		/*END PANEL 4*/
		
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// PANEL 5
		echo $pane->startPanel( JText::_('Ads'), 'ads' );
		?>
				<div class="left"><?php echo JText::_('Position of Ads')?></div>
				<div class="right">
					<input type="radio" <?php if($job->catads==0) echo 'checked'; ?> name="catads" value="0" /> <?php echo JText::_('Top of Intro')?>
					<input type="radio" <?php if($job->catads==1) echo 'checked'; ?> name="catads" value="1" /><?php echo JText::_('Bottom of Intro')?>
				</div>
				<div class="clr"></div>
				<div title="Put your ads'content in here" class="left texarea"><?php echo JText::_('Ads\'s Content')?></div>
				<div class="right"><textarea name="ads"  rows="5" cols="70"><?php echo $job->ads; ?></textarea> </div>
				<div class="clr"></div>
				
				
				
				<div class="left"><?php echo JText::_('Position of Title extend')?></div>
				<div class="right">
					<input type="radio" <?php if($job->title_ext_pos==0) echo 'checked'; ?> name="title_ext_pos" value="0" /> <?php echo JText::_('First of title')?>
					<input type="radio" <?php if($job->title_ext_pos==1) echo 'checked'; ?> name="title_ext_pos" value="1" /><?php echo JText::_('Last of title')?>
				</div>
				<div class="clr"></div>
				<div title="Title Extend" class="left texarea"><?= JText::_('Title Extend')?></div>
				<div class="right"><textarea name="title_ext"  rows="5" cols="70"><?= $job->title_ext; ?></textarea> </div>
				<div class="clr"></div>	
				
		<?php
		echo $pane->endPanel();
		/*END PANEL 5*/
		
		if ($job->error_counter ) {			
		// PANEL err
		echo $pane->startPanel( JText::_('Error msg'), 'err' );
				
		?>
			<div>
				<?= JText::_('Total').': '.$job->error_counter.' '.JText::_('Error(s)'); ?>
			</div>
			<br />
			<div id="joberr">
				<?= $job->error_msg; ?>		
			</div>
		<?php
		echo $pane->endPanel();
		/*END PANEL err*/
		}
		echo $pane->endPane();
		?>
		<input type="hidden" name="option" value="com_yos_news_crawler" />
		<input type="hidden" name="task" value="jobmanager" />
		<input type="hidden" id="cid" name="cid" value="<?= $job->id; ?>" />
		<input type="hidden" id="tab_active" name="tab_active" value="" />
		<?php echo JHTML::_( 'form.token' ); ?>		
	</form>
</div>